﻿
using Managers;
using Managers.LiveControl.Server;
using Managers.Nova.Server;
using Providers.Nova.Modules;
using System.Diagnostics;

namespace ConsleServer
{
   
    public class ServerManager
    {
        private NovaManager NovaManager => NovaServer.Instance.NovaManager;
        private LiveControlManager LiveControlManager => NovaServer.Instance.LiveControlManager;

        public async void Regist()
        {
            PasswordGeneratedEventArgs passArgs = await NovaManager.GeneratePassword();
            //IntroducerRegistrationResponsedEventArgs regArgs = await NovaManager.RegisterWithIntroducerAsTask();
            CheckMirrorDriverExists();
        }
        private void CheckMirrorDriverExists()
        {
            if (!LiveControlManager.Provider.DoesMirrorDriverExist())
            {
                Process.Start("http://www.demoforge.com/tightvnc/dfmirage-setup-2.0.301.exe");
                /* This error is referring to:
                 
            while (deviceFound = EnumDisplayDevices(null, deviceIndex, ref device, 0))
            {
                if (device.DeviceString == driverName)
                    break;
                deviceIndex++;
            }

            if (!deviceFound) return false;

                 * in MirrorDriver.DesktopMirror.cs. Basically, it enumerates through all of your graphic providers, and it's looking for "DF Mirage Driver", and it can't find it. Check Device Manager to verify that it's been installed (it's under Device Manager -> Display Adapters -> Mirage Driver). If you see it there, most likely you simply have to restart your computer.
                 */

                //var dialogResult =
                //     MessageBox.Show(
                //         "你没有安装demoforge镜像驱动器，或者你在安装后还没有重新启动您的计算机。没有镜像驱动程序，此应用程序将无法正常工作。镜像驱动程序负责通知任何改变屏幕区域的应用，通过这些改变屏幕区域应用位图。按“是”直接下载驱动程序（您之后仍然需要安装）. 你可以浏览以下网站: http://www.demoforge.com/dfmirage.htm",
                //         "M镜像驱动器没有安装", MessageBoxButtons.YesNo, MessageBoxIcon.Error);

                //if (dialogResult == DialogResult.Yes)
                //{
                //    Process.Start("http://www.demoforge.com/tightvnc/dfmirage-setup-2.0.301.exe");
                //}

            }
        }

    }
}
